﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BySoft.Web.Utility;
using BySoft.Server.Common;
using BySoft.Server.Consts;
using BySoft.Server.Common.Entity;
using BySoft.Server.Business;
using BySoft.Server.Common.Enum;
using OneSoft.EntityCore;
using BySoft.Web.Site;

namespace BySoft.Web.Site.SysManage
{
    public partial class FormCheckView : AuthBasePage
    {
        #region 属性定义

        private DataTable DtFormCheckData
        {
            get
            {
                if (null == Session["FormCheckData"])
                {
                    return CreateDT();
                }
                else
                {
                    return (DataTable)Session["FormCheckData"];
                }
            }
            set
            {
                Session["FormCheckData"] = value;
            }
        }

        private DataTable CreateDT()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("FormCheckDetailID");//0
            dt.Columns.Add("CheckUser");//1
            dt.Columns.Add("CheckUserName");//1
            dt.Columns.Add("OrderNum");//2
            dt.Columns.Add("IsDel");//2
            dt.Columns.Add("IsNew");//2
            return dt;
        }
        #endregion

        #region 初始化及绑定控件
        private void InitData()
        {
            DtFormCheckData = null;
            SetControlAttr(new SysFormauditEntity(), tBase);
            InitHead(hidFormCheckID.Value);
            BindData();
        }

        private void InitHead(string strCode)
        {
            DataTable dt = SysFormcheck.SelectHead(strCode);
            DataRow row = dt.Rows[0];
            chkIsCheck.Checked = CommonMethod.GetString(row["IsCheck"]).Equals("1");
            DataTable dttemp = CreateDT();
            foreach (DataRow dr in dt.Rows)
            {
                DataRow rowNew = dttemp.NewRow();
                rowNew["FormCheckDetailID"] = CommonMethod.GetString(dr["FormCheckDetailID"]);
                rowNew["CheckUser"] = CommonMethod.GetString(dr["CheckUser"]);
                rowNew["CheckUserName"] = CommonMethod.GetString(dr["UserName"]);
                rowNew["OrderNum"] = CommonMethod.GetString(dr["OrderNum"]);
                rowNew["IsDel"] = "-1";
                rowNew["IsNew"] = "-1";
                dttemp.Rows.Add(rowNew);
            }
            dttemp.AcceptChanges();
            DtFormCheckData = dttemp;
        }

        #endregion

        #region 控件事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hidFormCheckID.Value = UIHelper.GetQueryStringValue("id");
                grdResult.Style.Add("word-break", "keep-all");
                grdResult.Style.Add("word-wrap", "normal");
                InitData();
            }
            Master.ValidationGroup = "gSubmit";
            UIHelper.RunScript(this.UpdatePanel1, "Refreashtab();");
        } 
        private void BindData()
        {
            if (DtFormCheckData.Rows.Count > 0)
            {
                grdResult.DataSource = DtFormCheckData;
                grdResult.DataBind();
                SetControlAttr(new SysFormauditdetailEntity(), grdResult);
            }
            else
            {
                UIHelper.BindEmptyGridView(grdResult, CreateDT());
            }
            UIHelper.RunScript(this.UpdatePanel1, "iframeAutoFit();");
        }

      

         
        protected void grdResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                
            }
        }

        protected void grdResult_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
               
            }
        }
        #endregion

       
    }
}

